package com.example.java8.feature_05.func_interface;

import java.util.function.Supplier;

public class TestSupplier {

    /**
     * Supplier<T> 供给型接口
     * T:出参类型
     */
    public static void main(String[] args){

        // 使用lambda表达式创建supplier实例对象
        Supplier<Person> supplier = () -> {
            Person p = new Person();
            p.setName("珠圆玉润");
            return p;
        };

        Person p = supplier.get();
        System.out.println(p.getName());
    }


    public static class Person {
        private String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
